home *** CD-ROM | disk | FTP | other *** search
/ Champak 26 (Anniversary Edition) / Volume 26 [Anniversary Edition] - JOGO DISK .iso / Fight / sb_bust.swf / scripts / __Packages / PlayerObj.as < prev   
Text File  |  2006-07-26  |  12KB  |  462 lines

  1. class PlayerObj extends CharacterObj
  2. {
  3.    function PlayerObj(l_RefMov)
  4.    {
  5.       super(l_RefMov);
  6.       if(_global.Param.G_StartKO)
  7.       {
  8.          this.State = "WaitKO";
  9.          this.StateOld = "WaitKO";
  10.          l_RefMov.gotoAndStop(this.State);
  11.       }
  12.       this.RPress = false;
  13.       this.RRelease = true;
  14.       this.LPress = false;
  15.       this.LRelease = true;
  16.       this.SPress = false;
  17.       this.SRelease = true;
  18.       this.DPress = false;
  19.       this.DRelease = true;
  20.       this.DwPress = false;
  21.       this.SpPress = false;
  22.       this.SpRelease = true;
  23.       this.DoAttack = false;
  24.       this.ActionNow = "";
  25.       this.PunchRDammage = 5;
  26.       this.PunchLDammage = 5;
  27.       this.KickRDammage = 15;
  28.       this.KickLDammage = 15;
  29.       this.PunchRPts = 150;
  30.       this.PunchLPts = 150;
  31.       this.ParryPunchPts = 250;
  32.       this.KickRPts = 500;
  33.       this.KickLPts = 500;
  34.       this.PtSA = _global.Param.G_PtSA;
  35.       this.NbPtSAWin = 5;
  36.       this.HaveParry = false;
  37.       this.ParryTimeMax = 105;
  38.       this.ParryTime = 0;
  39.       this.AvoidAttack = "";
  40.    }
  41.    function Wait()
  42.    {
  43.    }
  44.    function WaitKO()
  45.    {
  46.    }
  47.    function Return()
  48.    {
  49.       if(this.RefMov.State._currentframe >= this.RefMov.State._totalframes)
  50.       {
  51.          _global.Param.G_StartKO = false;
  52.          _global.C.Enemy.ReturnIdle();
  53.          this.RefMov._parent.EndLock.gotoAndStop(1);
  54.          this.ReturnIdle();
  55.       }
  56.    }
  57.    function Idle()
  58.    {
  59.       if(this.WillWin)
  60.       {
  61.          this.RefMov._parent.EndLock.gotoAndStop(2);
  62.          this.State = "Win";
  63.       }
  64.    }
  65.    function StartParryR()
  66.    {
  67.       if(this.RefMov.State._currentframe == 3)
  68.       {
  69.          this.CanBeHit = false;
  70.       }
  71.       if(this.RefMov.State._currentframe >= this.RefMov.State._totalframes)
  72.       {
  73.          this.State = "ParryR";
  74.       }
  75.    }
  76.    function ParryR()
  77.    {
  78.       if(this.RefMov.State._currentframe >= this.RefMov.State._totalframes or !this.RPress)
  79.       {
  80.          this.State = "EndParryR";
  81.       }
  82.    }
  83.    function EndParryR()
  84.    {
  85.       if(this.RefMov.State._currentframe == 3)
  86.       {
  87.          this.CanBeHit = true;
  88.       }
  89.       if(this.RefMov.State._currentframe >= this.RefMov.State._totalframes)
  90.       {
  91.          this.ReturnIdle();
  92.       }
  93.    }
  94.    function StartParryL()
  95.    {
  96.       if(this.RefMov.State._currentframe == 3)
  97.       {
  98.          this.CanBeHit = false;
  99.       }
  100.       if(this.RefMov.State._currentframe >= this.RefMov.State._totalframes)
  101.       {
  102.          this.State = "ParryL";
  103.       }
  104.    }
  105.    function ParryL()
  106.    {
  107.       if(this.RefMov.State._currentframe >= this.RefMov.State._totalframes or !this.LPress)
  108.       {
  109.          this.State = "EndParryL";
  110.       }
  111.    }
  112.    function EndParryL()
  113.    {
  114.       if(this.RefMov.State._currentframe == 3)
  115.       {
  116.          this.CanBeHit = true;
  117.       }
  118.       if(this.RefMov.State._currentframe >= this.RefMov.State._totalframes)
  119.       {
  120.          this.ReturnIdle();
  121.       }
  122.    }
  123.    function StartPunchR()
  124.    {
  125.       if(this.RefMov.State._currentframe >= this.RefMov.State._totalframes)
  126.       {
  127.          this.CheckHit();
  128.          this.State = "EndPunchR";
  129.       }
  130.    }
  131.    function EndPunchR()
  132.    {
  133.       if(this.RefMov.State._currentframe >= this.RefMov.State._totalframes)
  134.       {
  135.          this.ReturnIdle();
  136.       }
  137.    }
  138.    function StartPunchL()
  139.    {
  140.       if(this.RefMov.State._currentframe >= this.RefMov.State._totalframes)
  141.       {
  142.          this.CheckHit();
  143.          this.State = "EndPunchL";
  144.       }
  145.    }
  146.    function EndPunchL()
  147.    {
  148.       if(this.RefMov.State._currentframe >= this.RefMov.State._totalframes)
  149.       {
  150.          this.ReturnIdle();
  151.       }
  152.    }
  153.    function StartKickR()
  154.    {
  155.       if(this.RefMov.State._currentframe >= this.RefMov.State._totalframes)
  156.       {
  157.          this.CheckHit();
  158.          this.State = "EndKickR";
  159.       }
  160.    }
  161.    function EndKickR()
  162.    {
  163.       if(this.RefMov.State._currentframe >= this.RefMov.State._totalframes)
  164.       {
  165.          this.ReturnIdle();
  166.       }
  167.    }
  168.    function StartKickL()
  169.    {
  170.       if(this.RefMov.State._currentframe >= this.RefMov.State._totalframes)
  171.       {
  172.          this.CheckHit();
  173.          this.State = "EndKickL";
  174.       }
  175.    }
  176.    function EndKickL()
  177.    {
  178.       if(this.RefMov.State._currentframe >= this.RefMov.State._totalframes)
  179.       {
  180.          this.ReturnIdle();
  181.       }
  182.    }
  183.    function StartSA()
  184.    {
  185.       if(this.RefMov.State._currentframe >= this.RefMov.State._totalframes)
  186.       {
  187.          _global.C.Garry.State = "IsThrow";
  188.          this.PtSA = 0;
  189.          this.RefMov._parent.Interface.PlayerSA.gotoAndStop(1);
  190.          this.State = "EndSA";
  191.       }
  192.    }
  193.    function EndSA()
  194.    {
  195.       if(this.RefMov.State._currentframe >= this.RefMov.State._totalframes)
  196.       {
  197.          this.ReturnIdle();
  198.       }
  199.    }
  200.    function GetHit()
  201.    {
  202.       if(this.RefMov.State._currentframe >= this.RefMov.State._totalframes)
  203.       {
  204.          this.CanBeHit = true;
  205.          this.State = "EndGetHit";
  206.       }
  207.    }
  208.    function EndGetHit()
  209.    {
  210.       if(this.RefMov.State._currentframe >= this.RefMov.State._totalframes)
  211.       {
  212.          this.ReturnIdle();
  213.       }
  214.    }
  215.    function Die()
  216.    {
  217.       if(this.RefMov.State._currentframe >= this.RefMov.State._totalframes)
  218.       {
  219.          _global.Param.G_StartKO = true;
  220.          _global.Param.G_PtSA = 0;
  221.          this.State = "Dead";
  222.          _global.C.Enemy.WillWin = true;
  223.       }
  224.    }
  225.    function Win()
  226.    {
  227.       if(this.RefMov.State._currentframe >= this.RefMov.State._totalframes and _global.Param._parent.RoundTransit._currentframe == 1)
  228.       {
  229.          _global.Param.G_Score += _global.Param.G_WinPts;
  230.          _global.Param.G_ShowScore("Game.ShowScore.TxtScore");
  231.          _global.Param.G_PtSA = this.PtSA;
  232.          _global.Param.G_Winner = this.Nom;
  233.          _global.Param.G_KeepHealth += this.Health;
  234.          _global.Param.G_PlayerWin = _global.Param.G_PlayerWin + 1;
  235.          _global.Param._parent.RoundTransit.gotoAndPlay(2);
  236.       }
  237.    }
  238.    function CheckControl()
  239.    {
  240.       this.SetParryTime();
  241.       this.KeyMapping();
  242.       this.SetAction();
  243.    }
  244.    function KeyMapping()
  245.    {
  246.       if(Key.isDown(39))
  247.       {
  248.          if(this.RRelease)
  249.          {
  250.             this.RPress = true;
  251.          }
  252.       }
  253.       else
  254.       {
  255.          this.RRelease = true;
  256.          this.RPress = false;
  257.       }
  258.       if(Key.isDown(37))
  259.       {
  260.          if(this.LRelease)
  261.          {
  262.             this.LPress = true;
  263.          }
  264.       }
  265.       else
  266.       {
  267.          this.LRelease = true;
  268.          this.LPress = false;
  269.       }
  270.       if(Key.isDown(38))
  271.       {
  272.          this.DwPress = true;
  273.       }
  274.       else
  275.       {
  276.          this.DwPress = false;
  277.       }
  278.       if(Key.isDown(68))
  279.       {
  280.          if(this.DRelease)
  281.          {
  282.             this.DPress = true;
  283.          }
  284.       }
  285.       else
  286.       {
  287.          this.DRelease = true;
  288.          this.DPress = false;
  289.       }
  290.       if(Key.isDown(83))
  291.       {
  292.          if(this.SRelease)
  293.          {
  294.             this.SPress = true;
  295.          }
  296.       }
  297.       else
  298.       {
  299.          this.SRelease = true;
  300.          this.SPress = false;
  301.       }
  302.       if(Key.isDown(32))
  303.       {
  304.          if(this.SpRelease)
  305.          {
  306.             this.SpPress = true;
  307.          }
  308.       }
  309.       else
  310.       {
  311.          this.SpRelease = true;
  312.          this.SpPress = false;
  313.       }
  314.    }
  315.    function SetAction()
  316.    {
  317.       if(this.State == "Idle" and !_global.C.G_RoundOver)
  318.       {
  319.          this.ActionNow = "";
  320.          if(this.RPress and !this.LPress and this.RRelease)
  321.          {
  322.             this.RRelease = false;
  323.             this.ActionNow = "ParryR";
  324.             this.State = "StartParryR";
  325.          }
  326.          if(this.LPress and !this.RPress and this.LRelease)
  327.          {
  328.             this.LRelease = false;
  329.             this.ActionNow = "ParryL";
  330.             this.State = "StartParryL";
  331.          }
  332.          if(this.DPress and !this.SPress and this.DRelease)
  333.          {
  334.             this.DRelease = false;
  335.             if(_global.C.Garry.State != "IsThrow")
  336.             {
  337.                this.DoAttack = true;
  338.                if(this.DwPress)
  339.                {
  340.                   this.ActionNow = "KickR";
  341.                   this.State = "StartKickR";
  342.                }
  343.                else
  344.                {
  345.                   this.ActionNow = "PunchR";
  346.                   this.State = "StartPunchR";
  347.                }
  348.             }
  349.          }
  350.          if(this.SPress and !this.DPress and this.SRelease)
  351.          {
  352.             this.SRelease = false;
  353.             if(_global.C.Garry.State != "IsThrow")
  354.             {
  355.                this.DoAttack = true;
  356.                if(this.DwPress)
  357.                {
  358.                   this.ActionNow = "KickL";
  359.                   this.State = "StartKickL";
  360.                }
  361.                else
  362.                {
  363.                   this.ActionNow = "PunchL";
  364.                   this.State = "StartPunchL";
  365.                }
  366.             }
  367.          }
  368.          if(this.SpPress and this.SpRelease and this.PtSA == 100 and this.State != "StartSA" and this.State != "EndSA")
  369.          {
  370.             this.SpRelease = false;
  371.             this.ActionNow = "SA";
  372.             this.State = "StartSA";
  373.          }
  374.       }
  375.    }
  376.    function CheckHit()
  377.    {
  378.       if(_global.C.Enemy.CanBeHit)
  379.       {
  380.          _global.C.Enemy.SetGetHit(this[this.ActionNow + "Dammage"]);
  381.          this.WinPts();
  382.       }
  383.       else if(_global.C.Enemy.State == "Parry" or _global.C.Enemy.State == "StartParry")
  384.       {
  385.          _global.C.Enemy.State = "ParryBloc";
  386.       }
  387.       else if(_global.C.Enemy.State == "ParryR" or _global.C.Enemy.State == "StartParryR")
  388.       {
  389.          _global.C.Enemy.State = "ParryBlocR";
  390.       }
  391.       else if(_global.C.Enemy.State == "ParryL" or _global.C.Enemy.State == "StartParryL")
  392.       {
  393.          _global.C.Enemy.State = "ParryBlocL";
  394.       }
  395.       this.DoAttack = false;
  396.    }
  397.    function SetGetHit(l_Dammage)
  398.    {
  399.       this.DoAttack = false;
  400.       this.CanBeHit = false;
  401.       this.Health -= l_Dammage;
  402.       if(this.Health < 0)
  403.       {
  404.          this.Health = 0;
  405.       }
  406.       var _loc3_ = this.NbFace - int(this.Health * this.NbFace / this.MaxHealth);
  407.       this.RefMov._parent.Interface[this.Nom + "Face"].gotoAndStop(_loc3_);
  408.       if(this.Health > 0)
  409.       {
  410.          this.State = "GetHit";
  411.       }
  412.       else
  413.       {
  414.          _global.C.G_RoundOver = true;
  415.          this.State = "Die";
  416.       }
  417.    }
  418.    function WinPts(l_Pts)
  419.    {
  420.       if(l_Pts == undefined)
  421.       {
  422.          if((this.ActionNow == "PunchR" or this.ActionNow == "PunchL") and this.HaveParry and this.ParryTime > 0)
  423.          {
  424.             _global.Param.G_Score += this.ParryPunchPts;
  425.             this.HaveParry = false;
  426.             this.ParryTime = 0;
  427.          }
  428.          else
  429.          {
  430.             _global.Param.G_Score += this[this.ActionNow + "Pts"];
  431.          }
  432.       }
  433.       else
  434.       {
  435.          _global.Param.G_Score += l_Pts;
  436.       }
  437.       _global.Param.G_ShowScore("Game.ShowScore.TxtScore");
  438.    }
  439.    function SetParryTime()
  440.    {
  441.       if(this.ParryTime > 0)
  442.       {
  443.          this.ParryTime = this.ParryTime - 1;
  444.          if(this.ParryTime == 0)
  445.          {
  446.             this.HaveParry = false;
  447.          }
  448.       }
  449.    }
  450.    function ReturnIdle()
  451.    {
  452.       if(this.HaveParry and (this.State == "EndParryL" or this.State == "EndParryR"))
  453.       {
  454.          this.ParryTime = this.ParryTimeMax;
  455.       }
  456.       _global.C.Enemy.TryParry = false;
  457.       this.AvoidAttack = "";
  458.       this.CanBeHit = true;
  459.       this.State = "Idle";
  460.    }
  461. }
  462.